home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / SCSI.p < prev    next >
Encoding:
Text File  |  1996-05-06  |  38.3 KB  |  956 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SCSI.p
  3.  
  4.      Contains:    SCSI Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.3
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT SCSI;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __SCSI__}
  30. {$SETC __SCSI__ := 1}
  31.  
  32. {$I+}
  33. {$SETC SCSIIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __MIXEDMODE__}
  43. {$I MixedMode.p}
  44. {$ENDC}
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49.  
  50. CONST
  51.     scInc                        = 1;
  52.     scNoInc                        = 2;
  53.     scAdd                        = 3;
  54.     scMove                        = 4;
  55.     scLoop                        = 5;
  56.     scNop                        = 6;
  57.     scStop                        = 7;
  58.     scComp                        = 8;
  59.  
  60. { SCSI Manager errors }
  61.     scCommErr                    = 2;                            { communications error, operation timeout }
  62.     scArbNBErr                    = 3;                            { arbitration timeout waiting for not BSY }
  63.     scBadParmsErr                = 4;                            { bad parameter or TIB opcode }
  64.     scPhaseErr                    = 5;                            { SCSI bus not in correct phase for attempted operation }
  65.     scCompareErr                = 6;                            { data compare error }
  66.     scMgrBusyErr                = 7;                            { SCSI Manager busy  }
  67.     scSequenceErr                = 8;                            { attempted operation is out of sequence }
  68.     scBusTOErr                    = 9;                            { CPU bus timeout }
  69.     scComplPhaseErr                = 10;                            { SCSI bus wasn't in Status phase }
  70.  
  71. { Signatures }
  72.     sbSIGWord                    = $4552;                        { signature word for Block 0 ('ER') }
  73.     sbMac                        = 1;                            { system type for Mac }
  74.     pMapSIG                        = $504D;                        { partition map signature ('PM') }
  75.     pdSigWord                    = $5453;
  76.  
  77.     oldPMSigWord                = pdSigWord;
  78.     newPMSigWord                = pMapSIG;
  79.  
  80. { Driver Descriptor Map }
  81.  
  82. TYPE
  83.     Block0 = PACKED RECORD
  84.         sbSig:                    INTEGER;                                { unique value for SCSI block 0 }
  85.         sbBlkSize:                INTEGER;                                { block size of device }
  86.         sbBlkCount:                LONGINT;                                { number of blocks on device }
  87.         sbDevType:                INTEGER;                                { device type }
  88.         sbDevId:                INTEGER;                                { device id }
  89.         sbData:                    LONGINT;                                { not used }
  90.         sbDrvrCount:            INTEGER;                                { driver descriptor count }
  91.         ddBlock:                LONGINT;                                { 1st driver's starting block }
  92.         ddSize:                    INTEGER;                                { size of 1st driver (512-byte blks) }
  93.         ddType:                    INTEGER;                                { system type (1 for Mac+) }
  94.         ddPad:                    ARRAY [0..242] OF INTEGER;                { ARRAY[0..242] OF INTEGER; not used }
  95.     END;
  96.  
  97. {Driver descriptor}
  98.     DDMap = RECORD
  99.         ddBlock:                LONGINT;                                { 1st driver's starting block }
  100.         ddSize:                    INTEGER;                                { size of 1st driver (512-byte blks) }
  101.         ddType:                    INTEGER;                                { system type (1 for Mac+) }
  102.     END;
  103.  
  104. { Partition Map Entry }
  105.     Partition = PACKED RECORD
  106.         pmSig:                    INTEGER;                                { unique value for map entry blk }
  107.         pmSigPad:                INTEGER;                                { currently unused }
  108.         pmMapBlkCnt:            LONGINT;                                { # of blks in partition map }
  109.         pmPyPartStart:            LONGINT;                                { physical start blk of partition }
  110.         pmPartBlkCnt:            LONGINT;                                { # of blks in this partition }
  111.         pmPartName:                PACKED ARRAY [0..31] OF CHAR;            { ASCII partition name }
  112.         pmParType:                PACKED ARRAY [0..31] OF CHAR;            { ASCII partition type }
  113.         pmLgDataStart:            LONGINT;                                { log. # of partition's 1st data blk }
  114.         pmDataCnt:                LONGINT;                                { # of blks in partition's data area }
  115.         pmPartStatus:            LONGINT;                                { bit field for partition status }
  116.         pmLgBootStart:            LONGINT;                                { log. blk of partition's boot code }
  117.         pmBootSize:                LONGINT;                                { number of bytes in boot code }
  118.         pmBootAddr:                LONGINT;                                { memory load address of boot code }
  119.         pmBootAddr2:            LONGINT;                                { currently unused }
  120.         pmBootEntry:            LONGINT;                                { entry point of boot code }
  121.         pmBootEntry2:            LONGINT;                                { currently unused }
  122.         pmBootCksum:            LONGINT;                                { checksum of boot code }
  123.         pmProcessor:            PACKED ARRAY [0..15] OF CHAR;            { ASCII for the processor type }
  124.         pmPad:                    ARRAY [0..187] OF INTEGER;                { ARRAY[0..187] OF INTEGER; not used }
  125.     END;
  126.  
  127. { TIB instruction }
  128.     SCSIInstr = RECORD
  129.         scOpcode:                INTEGER;
  130.         scParam1:                LONGINT;
  131.         scParam2:                LONGINT;
  132.     END;
  133.  
  134.  
  135. FUNCTION SCSIReset: OSErr;
  136.     {$IFC NOT GENERATINGCFM}
  137.     INLINE $4267, $A815;
  138.     {$ENDC}
  139. FUNCTION SCSIGet: OSErr;
  140.     {$IFC NOT GENERATINGCFM}
  141.     INLINE $3F3C, $0001, $A815;
  142.     {$ENDC}
  143. FUNCTION SCSISelect(targetID: INTEGER): OSErr;
  144.     {$IFC NOT GENERATINGCFM}
  145.     INLINE $3F3C, $0002, $A815;
  146.     {$ENDC}
  147. FUNCTION SCSICmd(buffer: Ptr; count: INTEGER): OSErr;
  148.     {$IFC NOT GENERATINGCFM}
  149.     INLINE $3F3C, $0003, $A815;
  150.     {$ENDC}
  151. FUNCTION SCSIRead(tibPtr: Ptr): OSErr;
  152.     {$IFC NOT GENERATINGCFM}
  153.     INLINE $3F3C, $0005, $A815;
  154.     {$ENDC}
  155. FUNCTION SCSIRBlind(tibPtr: Ptr): OSErr;
  156.     {$IFC NOT GENERATINGCFM}
  157.     INLINE $3F3C, $0008, $A815;
  158.     {$ENDC}
  159. FUNCTION SCSIWrite(tibPtr: Ptr): OSErr;
  160.     {$IFC NOT GENERATINGCFM}
  161.     INLINE $3F3C, $0006, $A815;
  162.     {$ENDC}
  163. FUNCTION SCSIWBlind(tibPtr: Ptr): OSErr;
  164.     {$IFC NOT GENERATINGCFM}
  165.     INLINE $3F3C, $0009, $A815;
  166.     {$ENDC}
  167. FUNCTION SCSIComplete(VAR stat: INTEGER; VAR message: INTEGER; wait: LONGINT): OSErr;
  168.     {$IFC NOT GENERATINGCFM}
  169.     INLINE $3F3C, $0004, $A815;
  170.     {$ENDC}
  171. FUNCTION SCSIStat: INTEGER;
  172.     {$IFC NOT GENERATINGCFM}
  173.     INLINE $3F3C, $000A, $A815;
  174.     {$ENDC}
  175. FUNCTION SCSISelAtn(targetID: INTEGER): OSErr;
  176.     {$IFC NOT GENERATINGCFM}
  177.     INLINE $3F3C, $000B, $A815;
  178.     {$ENDC}
  179. FUNCTION SCSIMsgIn(VAR message: INTEGER): OSErr;
  180.     {$IFC NOT GENERATINGCFM}
  181.     INLINE $3F3C, $000C, $A815;
  182.     {$ENDC}
  183. FUNCTION SCSIMsgOut(message: INTEGER): OSErr;
  184.     {$IFC NOT GENERATINGCFM}
  185.     INLINE $3F3C, $000D, $A815;
  186.     {$ENDC}
  187. {——————————————————————— New SCSI Manager Interface ———————————————————————}
  188.  
  189. CONST
  190.     scsiVERSION                    = 43;
  191.  
  192. { SCSI Manager function codes }
  193.     SCSINop                        = $00;                            { Execute nothing                                         }
  194.     SCSIExecIO                    = $01;                            { Execute the specified IO                             }
  195.     SCSIBusInquiry                = $03;                            { Get parameters for entire path of HBAs                 }
  196.     SCSIReleaseQ                = $04;                            { Release the frozen SIM queue for particular LUN         }
  197.     SCSIAbortCommand            = $10;                            { Abort the selected Control Block                      }
  198.     SCSIResetBus                = $11;                            { Reset the SCSI bus                                      }
  199.     SCSIResetDevice                = $12;                            { Reset the SCSI device                                  }
  200.     SCSITerminateIO                = $13;                            { Terminate any pending IO                              }
  201.     SCSIGetVirtualIDInfo        = $80;                            { Find out which bus old ID is on                         }
  202.     SCSILoadDriver                = $82;                            { Load a driver for a device ident                     }
  203.     SCSIOldCall                    = $84;                            { XPT->SIM private call for old-API                     }
  204.     SCSICreateRefNumXref        = $85;                            { Register a DeviceIdent to drvr RefNum xref             }
  205.     SCSILookupRefNumXref        = $86;                            { Get DeviceIdent to drvr RefNum xref                     }
  206.     SCSIRemoveRefNumXref        = $87;                            { Remove a DeviceIdent to drvr RefNum xref             }
  207.     SCSIRegisterWithNewXPT        = $88;                            { XPT has changed - SIM needs to re-register itself     }
  208.     vendorUnique                = $C0;                            { 0xC0 thru 0xFF }
  209.  
  210. { SCSI Callback Procedure Prototypes }
  211. { SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility }
  212. TYPE
  213.     SCSICallbackProcPtr = ProcPtr;  { PROCEDURE SCSICallback(scsiPB: UNIV Ptr); }
  214.     AENCallbackProcPtr = ProcPtr;  { PROCEDURE AENCallback; }
  215.     SIMInitProcPtr = ProcPtr;  { FUNCTION SIMInit(SIMinfoPtr: Ptr): OSErr; }
  216.     SIMActionProcPtr = ProcPtr;  { PROCEDURE SIMAction(scsiPB: UNIV Ptr; SIMGlobals: Ptr); }
  217.     SCSIProcPtr = ProcPtr;  { PROCEDURE SCSI; }
  218.     SCSIMakeCallbackProcPtr = ProcPtr;  { PROCEDURE SCSIMakeCallback(scsiPB: UNIV Ptr); }
  219.     SCSIInterruptPollProcPtr = ProcPtr;  { FUNCTION SCSIInterruptPoll(SIMGlobals: Ptr): LONGINT; }
  220.     SCSIInterruptProcPtr = ProcPtr;  { FUNCTION SCSIInterrupt(SIMGlobals: Ptr): LONGINT; }
  221.     SCSICallbackUPP = UniversalProcPtr;
  222.     AENCallbackUPP = UniversalProcPtr;
  223.     SIMInitUPP = UniversalProcPtr;
  224.     SIMActionUPP = UniversalProcPtr;
  225.     SCSIUPP = UniversalProcPtr;
  226.     SCSIMakeCallbackUPP = UniversalProcPtr;
  227.     SCSIInterruptPollUPP = UniversalProcPtr;
  228.     SCSIInterruptUPP = UniversalProcPtr;
  229.  
  230. CONST
  231.     uppSCSICallbackProcInfo = $000000C0; { PROCEDURE (4 byte param); }
  232.     uppAENCallbackProcInfo = $00000001; { PROCEDURE ; }
  233.     uppSIMInitProcInfo = $000000E1; { FUNCTION (4 byte param): 2 byte result; }
  234.     uppSIMActionProcInfo = $000003C1; { PROCEDURE (4 byte param, 4 byte param); }
  235.     uppSCSIProcInfo = $00000001; { PROCEDURE ; }
  236.     uppSCSIMakeCallbackProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  237.     uppSCSIInterruptPollProcInfo = $000000F1; { FUNCTION (4 byte param): 4 byte result; }
  238.     uppSCSIInterruptProcInfo = $000000F1; { FUNCTION (4 byte param): 4 byte result; }
  239.  
  240. FUNCTION NewSCSICallbackProc(userRoutine: SCSICallbackProcPtr): SCSICallbackUPP;
  241.     {$IFC NOT GENERATINGCFM }
  242.     INLINE $2E9F;
  243.     {$ENDC}
  244.  
  245. FUNCTION NewAENCallbackProc(userRoutine: AENCallbackProcPtr): AENCallbackUPP;
  246.     {$IFC NOT GENERATINGCFM }
  247.     INLINE $2E9F;
  248.     {$ENDC}
  249.  
  250. FUNCTION NewSIMInitProc(userRoutine: SIMInitProcPtr): SIMInitUPP;
  251.     {$IFC NOT GENERATINGCFM }
  252.     INLINE $2E9F;
  253.     {$ENDC}
  254.  
  255. FUNCTION NewSIMActionProc(userRoutine: SIMActionProcPtr): SIMActionUPP;
  256.     {$IFC NOT GENERATINGCFM }
  257.     INLINE $2E9F;
  258.     {$ENDC}
  259.  
  260. FUNCTION NewSCSIProc(userRoutine: SCSIProcPtr): SCSIUPP;
  261.     {$IFC NOT GENERATINGCFM }
  262.     INLINE $2E9F;
  263.     {$ENDC}
  264.  
  265. FUNCTION NewSCSIMakeCallbackProc(userRoutine: SCSIMakeCallbackProcPtr): SCSIMakeCallbackUPP;
  266.     {$IFC NOT GENERATINGCFM }
  267.     INLINE $2E9F;
  268.     {$ENDC}
  269.  
  270. FUNCTION NewSCSIInterruptPollProc(userRoutine: SCSIInterruptPollProcPtr): SCSIInterruptPollUPP;
  271.     {$IFC NOT GENERATINGCFM }
  272.     INLINE $2E9F;
  273.     {$ENDC}
  274.  
  275. FUNCTION NewSCSIInterruptProc(userRoutine: SCSIInterruptProcPtr): SCSIInterruptUPP;
  276.     {$IFC NOT GENERATINGCFM }
  277.     INLINE $2E9F;
  278.     {$ENDC}
  279.  
  280. PROCEDURE CallSCSICallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSICallbackUPP);
  281.     {$IFC NOT GENERATINGCFM}
  282.     INLINE $205F, $4E90;
  283.     {$ENDC}
  284.  
  285. PROCEDURE CallAENCallbackProc(userRoutine: AENCallbackUPP);
  286.     {$IFC NOT GENERATINGCFM}
  287.     INLINE $205F, $4E90;
  288.     {$ENDC}
  289.  
  290. FUNCTION CallSIMInitProc(SIMinfoPtr: Ptr; userRoutine: SIMInitUPP): OSErr;
  291.     {$IFC NOT GENERATINGCFM}
  292.     INLINE $205F, $4E90;
  293.     {$ENDC}
  294.  
  295. PROCEDURE CallSIMActionProc(scsiPB: UNIV Ptr; SIMGlobals: Ptr; userRoutine: SIMActionUPP);
  296.     {$IFC NOT GENERATINGCFM}
  297.     INLINE $205F, $4E90;
  298.     {$ENDC}
  299.  
  300. PROCEDURE CallSCSIProc(userRoutine: SCSIUPP);
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $205F, $4E90;
  303.     {$ENDC}
  304.  
  305. PROCEDURE CallSCSIMakeCallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSIMakeCallbackUPP);
  306.     {$IFC NOT GENERATINGCFM}
  307.     INLINE $205F, $4E90;
  308.     {$ENDC}
  309.  
  310. FUNCTION CallSCSIInterruptPollProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptPollUPP): LONGINT;
  311.     {$IFC NOT GENERATINGCFM}
  312.     INLINE $205F, $4E90;
  313.     {$ENDC}
  314.  
  315. FUNCTION CallSCSIInterruptProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptUPP): LONGINT;
  316.     {$IFC NOT GENERATINGCFM}
  317.     INLINE $205F, $4E90;
  318.     {$ENDC}
  319.  
  320. CONST
  321.     handshakeDataLength            = 8;                            { Handshake data length }
  322.     maxCDBLength                = 16;                            { Space for the CDB bytes/pointer }
  323.     vendorIDLength                = 16;                            { ASCII string len for Vendor ID  }
  324.  
  325. { Define DeviceIdent structure }
  326.  
  327. TYPE
  328.     DeviceIdent = PACKED RECORD
  329.         diReserved:                UInt8;                                    { reserved                 }
  330.         bus:                    UInt8;                                    { SCSI - Bus Number        }
  331.         targetID:                UInt8;                                    { SCSI - Target SCSI ID    }
  332.         LUN:                    UInt8;                                    { SCSI - LUN                  }
  333.     END;
  334.  
  335. { Command Descriptor Block structure }
  336.     CDB = RECORD
  337.         CASE INTEGER OF
  338.         0: (
  339.             cdbPtr:                        ^UInt8;                                { pointer to the CDB, or }
  340.            );
  341.         1: (
  342.             cdbBytes:                    PACKED ARRAY [0..maxCDBLength-1] OF SInt8; (* UInt8 *) { the actual CDB to send }
  343.            );
  344.     END;
  345.  
  346.     CDBPtr = ^CDB;
  347.  
  348. { Scatter/gather list element }
  349.     SGRecord = RECORD
  350.         SGAddr:                    Ptr;
  351.         SGCount:                UInt32;
  352.     END;
  353.  
  354. { SCSI Phases (used by SIMs to support the Original SCSI Manager }
  355.  
  356. CONST
  357.     kDataOutPhase                = 0;                            { Encoded MSG, C/D, I/O bits }
  358.     kDataInPhase                = 1;
  359.     kCommandPhase                = 2;
  360.     kStatusPhase                = 3;
  361.     kPhaseIllegal0                = 4;
  362.     kPhaseIllegal1                = 5;
  363.     kMessageOutPhase            = 6;
  364.     kMessageInPhase                = 7;
  365.     kBusFreePhase                = 8;                            { Additional Phases }
  366.     kArbitratePhase                = 9;
  367.     kSelectPhase                = 10;
  368.     kMessageInPhaseNACK            = 11;                            { Message In Phase with ACK hanging on the bus }
  369.  
  370.  
  371. TYPE
  372.     SCSIHdr = RECORD
  373.         qLink:                    ^SCSIHdr;
  374.         scsiReserved1:            INTEGER;
  375.         scsiPBLength:            UInt16;
  376.         scsiFunctionCode:        SInt8; (* UInt8 *)
  377.         scsiReserved2:            SInt8; (* UInt8 *)
  378.         scsiResult:                OSErr;
  379.         scsiDevice:                DeviceIdent;
  380.         scsiCompletion:            SCSICallbackUPP;
  381.         scsiFlags:                UInt32;
  382.         scsiDriverStorage:        ^UInt8;
  383.         scsiXPTprivate:            Ptr;
  384.         scsiReserved3:            LONGINT;
  385.     END;
  386.  
  387.     SCSI_PB = RECORD
  388.         qLink:                    ^SCSIHdr;
  389.         scsiReserved1:            INTEGER;
  390.         scsiPBLength:            UInt16;
  391.         scsiFunctionCode:        SInt8; (* UInt8 *)
  392.         scsiReserved2:            SInt8; (* UInt8 *)
  393.         scsiResult:                OSErr;
  394.         scsiDevice:                DeviceIdent;
  395.         scsiCompletion:            SCSICallbackUPP;
  396.         scsiFlags:                UInt32;
  397.         scsiDriverStorage:        ^UInt8;
  398.         scsiXPTprivate:            Ptr;
  399.         scsiReserved3:            LONGINT;
  400.     END;
  401.  
  402.     SCSI_IO = RECORD
  403.         qLink:                    ^SCSIHdr;
  404.         scsiReserved1:            INTEGER;
  405.         scsiPBLength:            UInt16;
  406.         scsiFunctionCode:        SInt8; (* UInt8 *)
  407.         scsiReserved2:            SInt8; (* UInt8 *)
  408.         scsiResult:                OSErr;
  409.         scsiDevice:                DeviceIdent;
  410.         scsiCompletion:            SCSICallbackUPP;
  411.         scsiFlags:                UInt32;
  412.         scsiDriverStorage:        ^UInt8;
  413.         scsiXPTprivate:            Ptr;
  414.         scsiReserved3:            LONGINT;
  415.         scsiResultFlags:        UInt16;
  416.         scsiReserved3pt5:        UInt16;
  417.         scsiDataPtr:            ^UInt8;
  418.         scsiDataLength:            UInt32;
  419.         scsiSensePtr:            ^UInt8;
  420.         scsiSenseLength:        SInt8; (* UInt8 *)
  421.         scsiCDBLength:            SInt8; (* UInt8 *)
  422.         scsiSGListCount:        UInt16;
  423.         scsiReserved4:            UInt32;
  424.         scsiSCSIstatus:            SInt8; (* UInt8 *)
  425.         scsiSenseResidual:        SInt8;
  426.         scsiReserved5:            UInt16;
  427.         scsiDataResidual:        LONGINT;
  428.         scsiCDB:                CDB;
  429.         scsiTimeout:            LONGINT;
  430.         scsiReserved5pt5:        ^UInt8;
  431.         scsiReserved5pt6:        UInt16;
  432.         scsiIOFlags:            UInt16;
  433.         scsiTagAction:            SInt8; (* UInt8 *)
  434.         scsiReserved6:            SInt8; (* UInt8 *)
  435.         scsiReserved7:            UInt16;
  436.         scsiSelectTimeout:        UInt16;
  437.         scsiDataType:            SInt8; (* UInt8 *)
  438.         scsiTransferType:        SInt8; (* UInt8 *)
  439.         scsiReserved8:            UInt32;
  440.         scsiReserved9:            UInt32;
  441.         scsiHandshake:            ARRAY [0..handshakeDataLength-1] OF UInt16;
  442.         scsiReserved10:            UInt32;
  443.         scsiReserved11:            UInt32;
  444.         scsiCommandLink:        ^SCSI_IO;
  445.         scsiSIMpublics:            ARRAY [0..7] OF SInt8; (* UInt8 *)
  446.         scsiAppleReserved6:        ARRAY [0..7] OF SInt8; (* UInt8 *)
  447.         scsiCurrentPhase:        UInt16;
  448.         scsiSelector:            INTEGER;
  449.         scsiOldCallResult:        OSErr;
  450.         scsiSCSImessage:        SInt8; (* UInt8 *)
  451.         XPTprivateFlags:        SInt8; (* UInt8 *)
  452.         XPTextras:                ARRAY [0..11] OF SInt8; (* UInt8 *)
  453.     END;
  454.  
  455.     SCSIExecIOPB = SCSI_IO;
  456.  
  457. { Bus inquiry PB }
  458.     SCSIBusInquiryPB = RECORD
  459.         qLink:                    ^SCSIHdr;
  460.         scsiReserved1:            INTEGER;
  461.         scsiPBLength:            UInt16;
  462.         scsiFunctionCode:        SInt8; (* UInt8 *)
  463.         scsiReserved2:            SInt8; (* UInt8 *)
  464.         scsiResult:                OSErr;
  465.         scsiDevice:                DeviceIdent;
  466.         scsiCompletion:            SCSICallbackUPP;
  467.         scsiFlags:                UInt32;
  468.         scsiDriverStorage:        ^UInt8;
  469.         scsiXPTprivate:            Ptr;
  470.         scsiReserved3:            LONGINT;
  471.         scsiEngineCount:        UInt16;                                    { <- Number of engines on HBA                         }
  472.         scsiMaxTransferType:    UInt16;                                    { <- Number of transfer types for this HBA            }
  473.         scsiDataTypes:            UInt32;                                    { <- which data types are supported by this SIM     }
  474.         scsiIOpbSize:            UInt16;                                    { <- Size of SCSI_IO PB for this SIM/HBA             }
  475.         scsiMaxIOpbSize:        UInt16;                                    { <- Size of max SCSI_IO PB for all SIM/HBAs         }
  476.         scsiFeatureFlags:        UInt32;                                    { <- Supported features flags field                 }
  477.         scsiVersionNumber:        SInt8; (* UInt8 *)                        { <- Version number for the SIM/HBA                 }
  478.         scsiHBAInquiry:            SInt8; (* UInt8 *)                        { <- Mimic of INQ byte 7 for the HBA                 }
  479.         scsiTargetModeFlags:    SInt8; (* UInt8 *)                        { <- Flags for target mode support                 }
  480.         scsiScanFlags:            SInt8; (* UInt8 *)                        { <- Scan related feature flags                     }
  481.         scsiSIMPrivatesPtr:        UInt32;                                    { <- Ptr to SIM private data area                     }
  482.         scsiSIMPrivatesSize:    UInt32;                                    { <- Size of SIM private data area                 }
  483.         scsiAsyncFlags:            UInt32;                                    { <- Event cap. for Async Callback                 }
  484.         scsiHiBusID:            SInt8; (* UInt8 *)                        { <- Highest path ID in the subsystem              }
  485.         scsiInitiatorID:        SInt8; (* UInt8 *)                        { <- ID of the HBA on the SCSI bus                 }
  486.         scsiBIReserved0:        UInt16;                                    {                                                    }
  487.         scsiBIReserved1:        UInt32;                                    { <-                                                  }
  488.         scsiFlagsSupported:        UInt32;                                    { <- which scsiFlags are supported                 }
  489.         scsiIOFlagsSupported:    UInt16;                                    { <- which scsiIOFlags are supported                 }
  490.         scsiWeirdStuff:            UInt16;                                    { <-                                                 }
  491.         scsiMaxTarget:            UInt16;                                    { <- maximum Target number supported                 }
  492.         scsiMaxLUN:                UInt16;                                    { <- maximum Logical Unit number supported         }
  493.         scsiSIMVendor:            PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Vendor ID of SIM (or XPT if bus<FF)         }
  494.         scsiHBAVendor:            PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Vendor ID of the HBA                         }
  495.         scsiControllerFamily:    PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Family of SCSI Controller                 }
  496.         scsiControllerType:        PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Specific Model of SCSI Controller used     }
  497.         scsiXPTversion:            PACKED ARRAY [0..3] OF CHAR;            { <- version number of XPT                         }
  498.         scsiSIMversion:            PACKED ARRAY [0..3] OF CHAR;            { <- version number of SIM                         }
  499.         scsiHBAversion:            PACKED ARRAY [0..3] OF CHAR;            { <- version number of HBA                         }
  500.         scsiHBAslotType:        SInt8; (* UInt8 *)                        { <- type of "slot" that this HBA is in            }
  501.         scsiHBAslotNumber:        SInt8; (* UInt8 *)                        { <- slot number of this HBA                         }
  502.         scsiSIMsRsrcID:            UInt16;                                    { <- resource ID of this SIM                         }
  503.         scsiBIReserved3:        UInt16;                                    { <-                                                 }
  504.         scsiAdditionalLength:    UInt16;                                    { <- additional BusInquiry PB len                    }
  505.     END;
  506.  
  507. { Abort SIM Request PB }
  508.     SCSIAbortCommandPB = RECORD
  509.         qLink:                    ^SCSIHdr;
  510.         scsiReserved1:            INTEGER;
  511.         scsiPBLength:            UInt16;
  512.         scsiFunctionCode:        SInt8; (* UInt8 *)
  513.         scsiReserved2:            SInt8; (* UInt8 *)
  514.         scsiResult:                OSErr;
  515.         scsiDevice:                DeviceIdent;
  516.         scsiCompletion:            SCSICallbackUPP;
  517.         scsiFlags:                UInt32;
  518.         scsiDriverStorage:        ^UInt8;
  519.         scsiXPTprivate:            Ptr;
  520.         scsiReserved3:            LONGINT;
  521.         scsiIOptr:                ^SCSI_IO;                                { Pointer to the PB to abort                        }
  522.     END;
  523.  
  524. { Terminate I/O Process Request PB }
  525.     SCSITerminateIOPB = RECORD
  526.         qLink:                    ^SCSIHdr;
  527.         scsiReserved1:            INTEGER;
  528.         scsiPBLength:            UInt16;
  529.         scsiFunctionCode:        SInt8; (* UInt8 *)
  530.         scsiReserved2:            SInt8; (* UInt8 *)
  531.         scsiResult:                OSErr;
  532.         scsiDevice:                DeviceIdent;
  533.         scsiCompletion:            SCSICallbackUPP;
  534.         scsiFlags:                UInt32;
  535.         scsiDriverStorage:        ^UInt8;
  536.         scsiXPTprivate:            Ptr;
  537.         scsiReserved3:            LONGINT;
  538.         scsiIOptr:                ^SCSI_IO;                                { Pointer to the PB to terminate                     }
  539.     END;
  540.  
  541. { Reset SCSI Bus PB }
  542.     SCSIResetBusPB = RECORD
  543.         qLink:                    ^SCSIHdr;
  544.         scsiReserved1:            INTEGER;
  545.         scsiPBLength:            UInt16;
  546.         scsiFunctionCode:        SInt8; (* UInt8 *)
  547.         scsiReserved2:            SInt8; (* UInt8 *)
  548.         scsiResult:                OSErr;
  549.         scsiDevice:                DeviceIdent;
  550.         scsiCompletion:            SCSICallbackUPP;
  551.         scsiFlags:                UInt32;
  552.         scsiDriverStorage:        ^UInt8;
  553.         scsiXPTprivate:            Ptr;
  554.         scsiReserved3:            LONGINT;
  555.     END;
  556.  
  557. { Reset SCSI Device PB }
  558.     SCSIResetDevicePB = RECORD
  559.         qLink:                    ^SCSIHdr;
  560.         scsiReserved1:            INTEGER;
  561.         scsiPBLength:            UInt16;
  562.         scsiFunctionCode:        SInt8; (* UInt8 *)
  563.         scsiReserved2:            SInt8; (* UInt8 *)
  564.         scsiResult:                OSErr;
  565.         scsiDevice:                DeviceIdent;
  566.         scsiCompletion:            SCSICallbackUPP;
  567.         scsiFlags:                UInt32;
  568.         scsiDriverStorage:        ^UInt8;
  569.         scsiXPTprivate:            Ptr;
  570.         scsiReserved3:            LONGINT;
  571.     END;
  572.  
  573. { Release SIM Queue PB }
  574.     SCSIReleaseQPB = RECORD
  575.         qLink:                    ^SCSIHdr;
  576.         scsiReserved1:            INTEGER;
  577.         scsiPBLength:            UInt16;
  578.         scsiFunctionCode:        SInt8; (* UInt8 *)
  579.         scsiReserved2:            SInt8; (* UInt8 *)
  580.         scsiResult:                OSErr;
  581.         scsiDevice:                DeviceIdent;
  582.         scsiCompletion:            SCSICallbackUPP;
  583.         scsiFlags:                UInt32;
  584.         scsiDriverStorage:        ^UInt8;
  585.         scsiXPTprivate:            Ptr;
  586.         scsiReserved3:            LONGINT;
  587.     END;
  588.  
  589. { SCSI Get Virtual ID Info PB }
  590.     SCSIGetVirtualIDInfoPB = RECORD
  591.         qLink:                    ^SCSIHdr;
  592.         scsiReserved1:            INTEGER;
  593.         scsiPBLength:            UInt16;
  594.         scsiFunctionCode:        SInt8; (* UInt8 *)
  595.         scsiReserved2:            SInt8; (* UInt8 *)
  596.         scsiResult:                OSErr;
  597.         scsiDevice:                DeviceIdent;
  598.         scsiCompletion:            SCSICallbackUPP;
  599.         scsiFlags:                UInt32;
  600.         scsiDriverStorage:        ^UInt8;
  601.         scsiXPTprivate:            Ptr;
  602.         scsiReserved3:            LONGINT;
  603.         scsiOldCallID:            UInt16;                                    { -> SCSI ID of device in question             }
  604.         scsiExists:                BOOLEAN;                                { <- true if device exists                     }
  605.     END;
  606.  
  607. { Create/Lookup/Remove RefNum for Device PB }
  608.     SCSIDriverPB = RECORD
  609.         qLink:                    ^SCSIHdr;
  610.         scsiReserved1:            INTEGER;
  611.         scsiPBLength:            UInt16;
  612.         scsiFunctionCode:        SInt8; (* UInt8 *)
  613.         scsiReserved2:            SInt8; (* UInt8 *)
  614.         scsiResult:                OSErr;
  615.         scsiDevice:                DeviceIdent;
  616.         scsiCompletion:            SCSICallbackUPP;
  617.         scsiFlags:                UInt32;
  618.         scsiDriverStorage:        ^UInt8;
  619.         scsiXPTprivate:            Ptr;
  620.         scsiReserved3:            LONGINT;
  621.         scsiDriver:                INTEGER;                                { -> DriverRefNum, For SetDriver, <- For GetNextDriver }
  622.         scsiDriverFlags:        UInt16;                                    { <> Details of driver/device                     }
  623.         scsiNextDevice:            DeviceIdent;                            { <- DeviceIdent of the NEXT Item in the list  }
  624.     END;
  625.  
  626. { Load Driver PB }
  627.     SCSILoadDriverPB = RECORD
  628.         qLink:                    ^SCSIHdr;
  629.         scsiReserved1:            INTEGER;
  630.         scsiPBLength:            UInt16;
  631.         scsiFunctionCode:        SInt8; (* UInt8 *)
  632.         scsiReserved2:            SInt8; (* UInt8 *)
  633.         scsiResult:                OSErr;
  634.         scsiDevice:                DeviceIdent;
  635.         scsiCompletion:            SCSICallbackUPP;
  636.         scsiFlags:                UInt32;
  637.         scsiDriverStorage:        ^UInt8;
  638.         scsiXPTprivate:            Ptr;
  639.         scsiReserved3:            LONGINT;
  640.         scsiLoadedRefNum:        INTEGER;                                { <- SIM returns refnum of driver                     }
  641.         scsiDiskLoadFailed:        BOOLEAN;                                { -> if true, indicates call after failure to load }
  642.     END;
  643.  
  644. { Defines for the scsiTransferType field }
  645.  
  646. CONST
  647.     scsiTransferBlind            = 0;
  648.     scsiTransferPolled            = 1;
  649.  
  650. { Defines for the scsiDataType field }
  651.     scsiDataBuffer                = 0;                            { single contiguous buffer supplied                  }
  652.     scsiDataTIB                    = 1;                            { TIB supplied (ptr in scsiDataPtr)                 }
  653.     scsiDataSG                    = 2;                            { scatter/gather list supplied                      }
  654.  
  655. { Defines for the SCSIMgr scsiResult field in the PB header. }
  656. {  $E100 thru  E1FF }
  657. { -$1EFF thru -1E00 }
  658. { -#7935 thru -7681  }
  659. { = 0xE100 }
  660.     scsiErrorBase                = -7936;
  661.  
  662.     scsiRequestInProgress        = 1;                            { 1     = PB request is in progress             }
  663. { Execution failed  00-2F }
  664.     scsiRequestAborted            = scsiErrorBase + 2;            { -7934 = PB request aborted by the host         }
  665.     scsiUnableToAbort            = scsiErrorBase + 3;            { -7933 = Unable to Abort PB request             }
  666.     scsiNonZeroStatus            = scsiErrorBase + 4;            { -7932 = PB request completed with an err     }
  667.     scsiUnused05                = scsiErrorBase + 5;            { -7931 =                                      }
  668.     scsiUnused06                = scsiErrorBase + 6;            { -7930 =                                      }
  669.     scsiUnused07                = scsiErrorBase + 7;            { -7929 =                                      }
  670.     scsiUnused08                = scsiErrorBase + 8;            { -7928 =                                      }
  671.     scsiUnableToTerminate        = scsiErrorBase + 9;            { -7927 = Unable to Terminate I/O PB req         }
  672.     scsiSelectTimeout            = scsiErrorBase + 10;            { -7926 = Target selection timeout             }
  673.     scsiCommandTimeout            = scsiErrorBase + 11;            { -7925 = Command timeout                      }
  674.     scsiIdentifyMessageRejected    = scsiErrorBase + 12;            { -7924 =                                      }
  675.     scsiMessageRejectReceived    = scsiErrorBase + 13;            { -7923 = Message reject received                 }
  676.     scsiSCSIBusReset            = scsiErrorBase + 14;            { -7922 = SCSI bus reset sent/received         }
  677.     scsiParityError                = scsiErrorBase + 15;            { -7921 = Uncorrectable parity error occured     }
  678.     scsiAutosenseFailed            = scsiErrorBase + 16;            { -7920 = Autosense: Request sense cmd fail     }
  679.     scsiUnused11                = scsiErrorBase + 17;            { -7919 =                                      }
  680.     scsiDataRunError            = scsiErrorBase + 18;            { -7918 = Data overrun/underrun error          }
  681.     scsiUnexpectedBusFree        = scsiErrorBase + 19;            { -7917 = Unexpected BUS free                     }
  682.     scsiSequenceFailed            = scsiErrorBase + 20;            { -7916 = Target bus phase sequence failure     }
  683.     scsiWrongDirection            = scsiErrorBase + 21;            { -7915 = Data phase was in wrong direction     }
  684.     scsiUnused16                = scsiErrorBase + 22;            { -7914 =                                      }
  685.     scsiBDRsent                    = scsiErrorBase + 23;            { -7913 = A SCSI BDR msg was sent to target     }
  686.     scsiTerminated                = scsiErrorBase + 24;            { -7912 = PB request terminated by the host     }
  687.     scsiNoNexus                    = scsiErrorBase + 25;            { -7911 = Nexus is not established             }
  688.     scsiCDBReceived                = scsiErrorBase + 26;            { -7910 = The SCSI CDB has been received         }
  689. { Couldn't begin execution  30-3F }
  690.     scsiTooManyBuses            = scsiErrorBase + 48;            { -7888 = Register failed because we're full    }
  691.     scsiBusy                    = scsiErrorBase + 49;            { -7887 = SCSI subsystem is busy                 }
  692.     scsiProvideFail                = scsiErrorBase + 50;            { -7886 = Unable to provide requ. capability    }
  693.     scsiDeviceNotThere            = scsiErrorBase + 51;            { -7885 = SCSI device not installed/there      }
  694.     scsiNoHBA                    = scsiErrorBase + 52;            { -7884 = No HBA detected Error                 }
  695.     scsiDeviceConflict            = scsiErrorBase + 53;            { -7883 = sorry, max 1 refNum per DeviceIdent     }
  696.     scsiNoSuchXref                = scsiErrorBase + 54;            { -7882 = no such RefNum xref                     }
  697.     scsiQLinkInvalid            = scsiErrorBase + 55;            { -7881 = pre-linked PBs not supported            
  698.                                                                    (The QLink field was nonzero)        }
  699. { Parameter errors  40-7F }
  700.     scsiPBLengthError            = scsiErrorBase + 64;            { -7872 = (scsiPBLength is insuf'ct/invalid     }
  701.     scsiFunctionNotAvailable    = scsiErrorBase + 65;            { -7871 = The requ. func is not available      }
  702.     scsiRequestInvalid            = scsiErrorBase + 66;            { -7870 = PB request is invalid                 }
  703.     scsiBusInvalid                = scsiErrorBase + 67;            { -7869 = Bus ID supplied is invalid              }
  704.     scsiTIDInvalid                = scsiErrorBase + 68;            { -7868 = Target ID supplied is invalid         }
  705.     scsiLUNInvalid                = scsiErrorBase + 69;            { -7867 = LUN supplied is invalid              }
  706.     scsiIDInvalid                = scsiErrorBase + 70;            { -7866 = The initiator ID is invalid          }
  707.     scsiDataTypeInvalid            = scsiErrorBase + 71;            { -7865 = scsiDataType requested not supported }
  708.     scsiTransferTypeInvalid        = scsiErrorBase + 72;            { -7864 = scsiTransferType field is too high     }
  709.     scsiCDBLengthInvalid        = scsiErrorBase + 73;            { -7863 = scsiCDBLength field is too big         }
  710.  
  711.     scsiExecutionErrors            = scsiErrorBase;
  712.     scsiNotExecutedErrors        = scsiTooManyBuses;
  713.     scsiParameterErrors            = scsiPBLengthError;
  714.  
  715. { Defines for the scsiResultFlags field }
  716.     scsiSIMQFrozen                = $0001;                        { The SIM queue is frozen w/this err            }
  717.     scsiAutosenseValid            = $0002;                        { Autosense data valid for target              }
  718.     scsiBusNotFree                = $0004;                        { At time of callback, SCSI bus is not free    }
  719.  
  720. { Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function }
  721.     kbSCSIDisableAutosense        = 29;                            { Disable auto sense feature                     }
  722.     kbSCSIFlagReservedA            = 28;                            {                                              }
  723.     kbSCSIFlagReserved0            = 27;                            {                                              }
  724.     kbSCSICDBLinked                = 26;                            { The PB contains a linked CDB                    }
  725.     kbSCSIQEnable                = 25;                            { Target queue actions are enabled                }
  726.     kbSCSICDBIsPointer            = 24;                            { The CDB field contains a pointer                }
  727.     kbSCSIFlagReserved1            = 23;                            {                                                 }
  728.     kbSCSIInitiateSyncData        = 22;                            { Attempt Sync data xfer and SDTR                }
  729.     kbSCSIDisableSyncData        = 21;                            { Disable sync, go to async                    }
  730.     kbSCSISIMQHead                = 20;                            { Place PB at the head of SIM Q                }
  731.     kbSCSISIMQFreeze            = 19;                            { Return the SIM Q to frozen state                }
  732.     kbSCSISIMQNoFreeze            = 18;                            { Disallow SIM Q freezing                        }
  733.     kbSCSIDoDisconnect            = 17;                            { Definitely do disconnect                        }
  734.     kbSCSIDontDisconnect        = 16;                            { Definitely don't disconnect                    }
  735.     kbSCSIDataReadyForDMA        = 15;                            { Data buffer(s) are ready for DMA                }
  736.     kbSCSIFlagReserved3            = 14;                            {                                                 }
  737.     kbSCSIDataPhysical            = 13;                            { SG/Buffer data ptrs are physical                }
  738.     kbSCSISensePhysical            = 12;                            { Autosense buffer ptr is physical                }
  739.     kbSCSIFlagReserved5            = 11;                            {                                                 }
  740.     kbSCSIFlagReserved6            = 10;                            {                                                 }
  741.     kbSCSIFlagReserved7            = 9;                            {                                                 }
  742.     kbSCSIFlagReserved8            = 8;                            {                                                 }
  743.     kbSCSIDataBufferValid        = 7;                            { Data buffer valid                            }
  744.     kbSCSIStatusBufferValid        = 6;                            { Status buffer valid                             }
  745.     kbSCSIMessageBufferValid    = 5;                            { Message buffer valid                            }
  746.     kbSCSIFlagReserved9            = 4;                            {                                              }
  747.  
  748. { Defines for the bit masks of the scsiFlags field }
  749.     scsiDirectionMask            = $C0000000;                    { Data direction mask                        }
  750.     scsiDirectionNone            = $C0000000;                    { Data direction (11: no data)                }
  751.     scsiDirectionReserved        = $00000000;                    { Data direction (00: reserved)            }
  752.     scsiDirectionOut            = $80000000;                    { Data direction (10: DATA OUT)            }
  753.     scsiDirectionIn                = $40000000;                    { Data direction (01: DATA IN)                }
  754.     scsiDisableAutosense        = $20000000;                    { Disable auto sense feature                }
  755.     scsiFlagReservedA            = $10000000;                    {                                             }
  756.     scsiFlagReserved0            = $08000000;                    {                                             }
  757.     scsiCDBLinked                = $04000000;                    { The PB contains a linked CDB                }
  758.     scsiQEnable                    = $02000000;                    { Target queue actions are enabled            }
  759.     scsiCDBIsPointer            = $01000000;                    { The CDB field contains a pointer            }
  760.     scsiFlagReserved1            = $00800000;                    {                                             }
  761.     scsiInitiateSyncData        = $00400000;                    { Attempt Sync data xfer and SDTR            }
  762.     scsiDisableSyncData            = $00200000;                    { Disable sync, go to async                }
  763.     scsiSIMQHead                = $00100000;                    { Place PB at the head of SIM Q            }
  764.     scsiSIMQFreeze                = $00080000;                    { Return the SIM Q to frozen state            }
  765.     scsiSIMQNoFreeze            = $00040000;                    { Disallow SIM Q freezing                    }
  766.     scsiDoDisconnect            = $00020000;                    { Definitely do disconnect                    }
  767.     scsiDontDisconnect            = $00010000;                    { Definitely don't disconnect                }
  768.     scsiDataReadyForDMA            = $00008000;                    { Data buffer(s) are ready for DMA            }
  769.     scsiFlagReserved3            = $00004000;                    {  }
  770.     scsiDataPhysical            = $00002000;                    { SG/Buffer data ptrs are physical            }
  771.     scsiSensePhysical            = $00001000;                    { Autosense buffer ptr is physical            }
  772.     scsiFlagReserved5            = $00000800;                    {                                          }
  773.     scsiFlagReserved6            = $00000400;                    {                                             }
  774.     scsiFlagReserved7            = $00000200;                    {                                             }
  775.     scsiFlagReserved8            = $00000100;                    {                                             }
  776.  
  777. { bit masks for the scsiIOFlags field in SCSIExecIOPB }
  778.     scsiNoParityCheck            = $0002;                        { disable parity checking                             }
  779.     scsiDisableSelectWAtn        = $0004;                        { disable select w/Atn                              }
  780.     scsiSavePtrOnDisconnect        = $0008;                        { do SaveDataPointer upon Disconnect msg             }
  781.     scsiNoBucketIn                = $0010;                        { don’t bit bucket in during this I/O                 }
  782.     scsiNoBucketOut                = $0020;                        { don’t bit bucket out during this I/O             }
  783.     scsiDisableWide                = $0040;                        { disable wide transfer negotiation                 }
  784.     scsiInitiateWide            = $0080;                        { initiate wide transfer negotiation                 }
  785.     scsiRenegotiateSense        = $0100;                        { renegotiate sync/wide before issuing autosense     }
  786.     scsiDisableDiscipline        = $0200;                        { disable parameter checking on SCSIExecIO calls    }
  787.     scsiIOFlagReserved0080        = $0080;                        {                                                  }
  788.     scsiIOFlagReserved8000        = $8000;                        {                                                     }
  789.  
  790. { Defines for the SIM/HBA queue actions.  These values are used in the }
  791. { SCSIExecIOPB, for the queue action field. [These values should match the }
  792. { defines from some other include file for the SCSI message phases.  We may }
  793. { not need these definitions here. ] }
  794.     scsiSimpleQTag                = $20;                            { Tag for a simple queue                                 }
  795.     scsiHeadQTag                = $21;                            { Tag for head of queue                                  }
  796.     scsiOrderedQTag                = $22;                            { Tag for ordered queue                                 }
  797.  
  798. { Defines for the Bus Inquiry PB fields. }
  799. { scsiHBAInquiry field bits }
  800.     scsiBusMDP                    = $80;                            { Supports Modify Data Pointer message                        }
  801.     scsiBusWide32                = $40;                            { Supports 32 bit wide SCSI                                }
  802.     scsiBusWide16                = $20;                            { Supports 16 bit wide SCSI                                }
  803.     scsiBusSDTR                    = $10;                            { Supports Sync Data Transfer Req message                    }
  804.     scsiBusLinkedCDB            = $08;                            { Supports linked CDBs                                        }
  805.     scsiBusTagQ                    = $02;                            { Supports tag queue message                                }
  806.     scsiBusSoftReset            = $01;                            { Supports soft reset                                        }
  807.  
  808. { scsiDataTypes field bits  }
  809. {    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved }
  810.     scsiBusDataTIB                = 0+(1 * (2**(scsiDataTIB)));    { TIB supplied (ptr in scsiDataPtr)        }
  811.     scsiBusDataBuffer            = 0+(1 * (2**(scsiDataBuffer))); { single contiguous buffer supplied         }
  812.     scsiBusDataSG                = 0+(1 * (2**(scsiDataSG)));    { scatter/gather list supplied             }
  813.     scsiBusDataReserved            = $80000000;                    {                                           }
  814.  
  815. { scsiScanFlags field bits }
  816.     scsiBusScansDevices            = $80;                            { Bus scans for and maintains device list            }
  817.     scsiBusScansOnInit            = $40;                            { Bus scans performed at power-up/reboot            }
  818.     scsiBusLoadsROMDrivers        = $20;                            { may load ROM drivers to support targets             }
  819.  
  820. { scsiFeatureFlags field bits }
  821.     scsiBusInternalExternalMask    = $000000C0;                    { bus internal/external mask                    }
  822.     scsiBusInternalExternalUnknown = $00000000;                    { not known whether bus is inside or outside     }
  823.     scsiBusInternalExternal        = $000000C0;                    { bus goes inside and outside the box             }
  824.     scsiBusInternal                = $00000080;                    { bus goes inside the box                         }
  825.     scsiBusExternal                = $00000040;                    { bus goes outside the box                     }
  826.     scsiBusCacheCoherentDMA        = $00000020;                    { DMA is cache coherent                         }
  827.     scsiBusOldCallCapable        = $00000010;                    { SIM is old call capable                         }
  828.     scsiBusDifferential            = $00000004;                    { Single Ended (0) or Differential (1)         }
  829.     scsiBusFastSCSI                = $00000002;                    { HBA supports fast SCSI                         }
  830.     scsiBusDMAavailable            = $00000001;                    { DMA is available                             }
  831.  
  832. { scsiWeirdStuff field bits }
  833.     scsiOddDisconnectUnsafeRead1 = $0001;                        { Disconnects on odd byte boundries are unsafe with DMA and/or blind reads }
  834.     scsiOddDisconnectUnsafeWrite1 = $0002;                        { Disconnects on odd byte boundries are unsafe with DMA and/or blind writes }
  835.     scsiBusErrorsUnsafe            = $0004;                        { Non-handshaked delays or disconnects during blind transfers may cause a crash }
  836.     scsiRequiresHandshake        = $0008;                        { Non-handshaked delays or disconnects during blind transfers may cause data corruption }
  837.     scsiTargetDrivenSDTRSafe    = $0010;                        { Targets which initiate synchronous negotiations are supported }
  838.     scsiOddCountForPhysicalUnsafe = $0020;                        { If using physical addrs all counts must be even, and disconnects must be on even boundries }
  839.  
  840. { scsiHBAslotType values }
  841.     scsiMotherboardBus            = $00;                            { A built in Apple supplied bus                     }
  842.     scsiNuBus                    = $01;                            { A SIM on a NuBus card                             }
  843.     scsiPDSBus                    = $03;                            {    "  on a PDS card                                }
  844.     scsiPCIBus                    = $04;                            {    "  on a PCI bus card                            }
  845.     scsiPCMCIABus                = $05;                            {    "  on a PCMCIA card                            }
  846.     scsiFireWireBridgeBus        = $06;                            {    "  connected through a FireWire bridge        }
  847.  
  848. { Defines for the scsiDriverFlags field (in SCSIDriverPB) }
  849.     scsiDeviceSensitive            = $0001;                        { Only driver should access this device                }
  850.     scsiDeviceNoOldCallAccess    = $0002;                        { no old call access to this device                     }
  851.  
  852. {  SIMInitInfo PB }
  853. { directions are for SCSIRegisterBus call ( -> parm, <- result)             }
  854.  
  855. TYPE
  856.     SIMInitInfo = RECORD
  857.         SIMstaticPtr:            ^UInt8;                                    { <- alloc. ptr to the SIM's static vars                 }
  858.         staticSize:                LONGINT;                                { -> num bytes SIM needs for static vars                 }
  859.         SIMInit:                SIMInitUPP;                                { -> pointer to the SIM init routine                     }
  860.         SIMAction:                SIMActionUPP;                            { -> pointer to the SIM action routine                 }
  861.         SIM_ISR:                SCSIInterruptUPP;                        {       reserved                                             }
  862.         SIMInterruptPoll:        SCSIInterruptUPP;                        { -> pointer to the SIM interrupt poll routine            }
  863.         NewOldCall:                SIMActionUPP;                            { -> pointer to the SIM NewOldCall routine                }
  864.         ioPBSize:                UInt16;                                    { -> size of SCSI_IO_PBs required for this SIM            }
  865.         oldCallCapable:            BOOLEAN;                                { -> true if this SIM can handle old-API calls            }
  866.         simInfoUnused1:            SInt8; (* UInt8 *)                        {       reserved                                            }
  867.         simInternalUse:            LONGINT;                                { xx not affected or viewed by XPT                        }
  868.         XPT_ISR:                SCSIUPP;                                {    reserved                                            }
  869.         EnteringSIM:            SCSIUPP;                                { <- ptr to the EnteringSIM routine                    }
  870.         ExitingSIM:                SCSIUPP;                                { <- ptr to the ExitingSIM routine                        }
  871.         MakeCallback:            SCSIMakeCallbackUPP;                    { <- the XPT layer’s SCSIMakeCallback routine            }
  872.         busID:                    UInt16;                                    { <- bus number for the registered bus                    }
  873.         simSlotNumber:            SInt8; (* UInt8 *)                        { <- Magic cookie to place in scsiHBASlotNumber (PCI)    }
  874.         simSRsrcID:                SInt8; (* UInt8 *)                        { <- Magic cookie to place in scsiSIMsRsrcID     (PCI)    }
  875.         simRegEntry:            Ptr;                                    { -> The SIM's RegEntryIDPtr                     (PCI)    }
  876.     END;
  877.  
  878. { Glue between SCSI calls and SCSITrap format }
  879.  
  880. CONST
  881.     xptSCSIAction                = $0001;
  882.     xptSCSIRegisterBus            = $0002;
  883.     xptSCSIDeregisterBus        = $0003;
  884.     xptSCSIReregisterBus        = $0004;
  885.     xptSCSIKillXPT                = $0005;                        { kills Mini-XPT after transition }
  886.     xptSCSIInitialize            = $000A;                        { Initialize the SCSI manager }
  887.  
  888. { SCSI status}
  889.     scsiStatGood                = $00;                            { Good Status}
  890.     scsiStatCheckCondition        = $02;                            { Check Condition}
  891.     scsiStatConditionMet        = $04;                            { Condition Met}
  892.     scsiStatBusy                = $08;                            { Busy}
  893.     scsiStatIntermediate        = $10;                            { Intermediate}
  894.     scsiStatIntermedMet            = $14;                            { Intermediate - Condition Met}
  895.     scsiStatResvConflict        = $18;                            { Reservation conflict}
  896.     scsiStatTerminated            = $20;                            { Command terminated}
  897.     scsiStatQFull                = $28;                            { Queue full}
  898.  
  899. { SCSI messages}
  900.     kCmdCompleteMsg                = 0;
  901.     kExtendedMsg                = 1;                            { 0x01}
  902.     kSaveDataPointerMsg            = 2;                            { 0x02}
  903.     kRestorePointersMsg            = 3;                            { 0x03}
  904.     kDisconnectMsg                = 4;                            { 0x04}
  905.     kInitiatorDetectedErrorMsg    = 5;                            { 0x05}
  906.     kAbortMsg                    = 6;                            { 0x06}
  907.     kMsgRejectMsg                = 7;                            { 0x07}
  908.     kNoOperationMsg                = 8;                            { 0x08}
  909.     kMsgParityErrorMsg            = 9;                            { 0x09}
  910.     kLinkedCmdCompleteMsg        = 10;                            { 0x0a}
  911.     kLinkedCmdCompleteWithFlagMsg = 11;                            { 0x0b}
  912.     kBusDeviceResetMsg            = 12;                            { 0x0c}
  913.     kAbortTagMsg                = 13;                            { 0x0d}
  914.     kClearQueueMsg                = 14;                            { 0x0e}
  915.     kInitiateRecoveryMsg        = 15;                            { 0x0f}
  916.     kReleaseRecoveryMsg            = 16;                            { 0x10}
  917.     kTerminateIOProcessMsg        = 17;                            { 0x11}
  918.     kSimpleQueueTag                = $20;                            { 0x20}
  919.     kHeadOfQueueTagMsg            = 33;                            { 0x21}
  920.     kOrderedQueueTagMsg            = 34;                            { 0x22}
  921.     kIgnoreWideResidueMsg        = 35;                            { 0x23}
  922.  
  923. { moveq #kSCSIx, D0;  _SCSIAtomic }
  924.  
  925. FUNCTION SCSIAction(VAR parameterBlock: SCSI_PB): OSErr;
  926.     {$IFC NOT GENERATINGCFM}
  927.     INLINE $205F, $7001, $A089, $3E80;
  928.     {$ENDC}
  929. FUNCTION SCSIRegisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  930.     {$IFC NOT GENERATINGCFM}
  931.     INLINE $205F, $7002, $A089, $3E80;
  932.     {$ENDC}
  933. FUNCTION SCSIDeregisterBus(VAR parameterBlock: SCSI_PB): OSErr;
  934.     {$IFC NOT GENERATINGCFM}
  935.     INLINE $205F, $7003, $A089, $3E80;
  936.     {$ENDC}
  937. FUNCTION SCSIReregisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  938.     {$IFC NOT GENERATINGCFM}
  939.     INLINE $205F, $7004, $A089, $3E80;
  940.     {$ENDC}
  941. FUNCTION SCSIKillXPT(VAR parameterBlock: SIMInitInfo): OSErr;
  942.     {$IFC NOT GENERATINGCFM}
  943.     INLINE $205F, $7005, $A089, $3E80;
  944.     {$ENDC}
  945.  
  946. {$ALIGN RESET}
  947. {$POP}
  948.  
  949. {$SETC UsingIncludes := SCSIIncludes}
  950.  
  951. {$ENDC} {__SCSI__}
  952.  
  953. {$IFC NOT UsingIncludes}
  954.  END.
  955. {$ENDC}
  956.